package com.zxy.supplier_system.server.service

import com.zxy.supplier_system.server.controller.GeneralGoodsCategoryController
import com.zxy.supplier_system.server.repository.BusinessGeneralGoodsCategoryRepository
import org.springframework.stereotype.Service

@Service
class BusinessGeneralGoodsCategoryService(
    private val businessGeneralGoodsCategoryRepository: BusinessGeneralGoodsCategoryRepository,
    private val systemServiceService: SystemServiceService,
) {
    fun findAllTreeNodes(): List<GeneralGoodsCategoryController.GeneralGoodsCategoryNodeResponse> {
        return GeneralGoodsCategoryController.GeneralGoodsCategoryNodeResponse.flatCategoriesToNodeTree(
            this.businessGeneralGoodsCategoryRepository.findFlatCategoriesBySystemServiceId(
                systemServiceService.getCurrentSystemService().id
            )
        )
    }

}
